package com.liwen.service.util;

import com.alibaba.fastjson.JSONObject;

/**
 * @author: li.rui
 * @time: 2017-11-06 19:40
 * @description:
 */
public class FastJsonUtil {
    public static float getFloatValue(JSONObject obj, String key) {
        Float val = obj.getFloat(key);
        return null == val ? 0.0f : val;
    }

    public static int getIntValue(JSONObject obj, String key) {
        Integer val = obj.getInteger(key);
        return null == val ? 0 : val;
    }

    public static String getNotNullString(JSONObject obj, String key) {
        String temp = obj.getString(key);
        if (temp == null || temp.length() <= 0) {
            temp = "0";
        }
        return temp;
    }
}
